home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / minix / libsrc~1.z / libsrc~1 / ffs.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-12-28  |  242 b   |  22 lines

  1. #include "lib.h"
  2.  
  3. /*  ffs(3)
  4.  *
  5.  *  Author: Terrence W. Holm          Sep. 1988
  6.  */
  7.  
  8.  
  9. int ffs( word )
  10.   int word;
  11.  
  12.   {
  13.   int i;
  14.  
  15.   if ( word == 0 )
  16.     return( 0 );
  17.  
  18.   for ( i = 1;  ;  ++i, word >>= 1 )
  19.     if ( word & 1 )
  20.     return( i );
  21.   }
  22.